package com.wxhandle.cleandemo.api.exception;

import com.wxhandle.cleandemo.api.exception.DomainException.ErrorCode;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;

@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Data
public class ErrorResult {
    int code;
    String message;
    String details;

    public static ErrorResult ofException(DomainException ex){
        return new ErrorResult(ex.getCode(), ex.getCodeMsg(), ex.getMsg());
    }

    public static ErrorResult ofErrorCode(ErrorCode code, String detail){
        return new ErrorResult(code.getCode(), code.getMsg(), detail);
    }
}